<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<c:choose>
	<c:when test="${image.new}"><c:set var="method" value="post"/></c:when>
	<c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>
<h2><c:if test="${image.new}">New image</c:if><c:if test="${!image.new}">${image.name}</c:if></h2>

<b>Album:</b> <a href="/albums/albums/${image.album.id}">${image.album.name}</a>
<br/>
<form:form method="${method}" enctype="multipart/form-data">
  <table>
    <tr>
      <th>
        Name: <form:errors path="image.name" cssClass="errors"/>
        <br/>
<%--
        <form:input path="image.name" size="30" maxlength="30"/>
--%>
          <input type="text" name="name1" value="<c:if test="${!image.new}">${image.name}</c:if>"/>
      </th>
    </tr>
    <tr>
      <th>
        Thumb: <form:errors path="image.thumb" cssClass="errors"/>
        <br/>
          <input type="file" name="thumb1"/>
        <%--<form:input path="thumb" size="10" maxlength="10"/>--%>
      </th>
    </tr>
    <tr>
      <th>
        Image: <form:errors path="image.image" cssClass="errors"/>
        <br/>
          <input type="file" name="image1"/>
        <%--<form:input path="image" size="10" maxlength="10"/>--%>
      </th>
    </tr>
    <tr>
      <td>
        <c:choose>
          <c:when test="${image.new}">
            <p class="submit"><input type="submit" value="Add image"/></p>
          </c:when>
          <c:otherwise>
            <p class="submit"><input type="submit" value="Update image"/></p>
          </c:otherwise>
        </c:choose>
      </td>
    </tr>
  </table>
</form:form>

<c:if test="${!image.new}">
  <form:form method="delete">
    <p class="submit"><input type="submit" value="Delete image"/></p>
  </form:form>
</c:if>    

<%@ include file="/WEB-INF/jsp/footer.jsp" %>
